(*
 *
 *)

module type SigEnv =
  sig
    type ('a,'b) t
    exception KNE
 
    val emptyenv: (string,'b) t
    val isemptyenv : (string,'b) t -> bool
    val addenv : (string * 'b) -> (string,'b) t -> (string,'b) t
    val updateenv : (string * 'b) -> (string,'b) t -> (string,'b) t
    val addenvlist: (string * 'b) list -> (string,'b) t -> (string, 'b)t
    val isindom : string -> (string,'b) t -> bool
    val valinenv : string -> (string,'b) t -> 'b
    val env2list : (string, 'b)t -> (string * 'b)list
  end


module Env(MyMap: SigMap) : SigEnv =
  struct
    type ('a,'b) t = ('a, 'b) MyMap.t
    exception KNE


    let emptyenv = MyMap.createmap

    let isemptyenv e = MyMap.isempty e

    let addenv (k,v) e = MyMap.addmap (k,v) e

    let updateenv (k,v) e = MyMap.updatemap (k,v) e
    
    let rec addenvlist kvl e =
       match kvl with
         [] -> e
       | h::t -> let e1 = addenv h e
                 in addenvlist t e1

    let isindom k e = MyMap.isinmap k e

    let valinenv k e = MyMap.lookupmap k e

    let env2list e = MyMap.map2list e
  end

